<!DOCTYPE html >

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Pagination 分页表格</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
    
    <script src="__PUBLIC__/scripts/boot.js" type="text/javascript"></script>
    
        
</head>
<body>
    <h1>项目文件总览</h1>
    
       <div style="width:900px;">
        <div class="mini-toolbar" style="padding:2px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                    <span>项目名称: {$_SESSION['pname']}</span>
                     &nbsp
                     <span>项目经理: {$_SESSION['managername']}</span>
                    
                    <td style="white-space:nowrap;">
					 <span>文件名称：</span><input type="text" id="key"  />
					<input type="button" value="查找" onclick="search()"/>
                    <a class="mini-button mini-button-iconTop" iconCls="icon-download"  onclick="batchdown()" plain="true">项目全部文件批量下载</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div> 
     <br />
  

<div id="datagrid1" class="mini-datagrid" style="width:900px;height:300px;" 
    url="__APP__/Post/showfile"  idField="id" allowResize="true"
    sizeList="[10,20,30,50]" pageSize="10"  
>
    <div property="columns">
        <div type="indexcolumn" >序号</div>
        <div field="orginalname" width="120" headerAlign="center" allowSort="true">文件名称</div>    
        <div field="level" width="80" headerAlign="center" allowSort="true">所属阶段</div> 
		<div name="action" width="120" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>		  		
    </div>
</div>   


    <script type="text/javascript">
        mini.parse();       
	
           
        var grid = mini.get("datagrid1");
   
        grid.load();
        
        var pid="{$_SESSION['pid']}";
		if(pid.length<1)
          {
          	mini.alert("尚未选择项目！","提示",function(){window.CloseOwnerWindow('refresh');});
    	
         }
         
         $("#key").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                search();	
            }
        });
         var t = mini.get("date");
         t.setValue(new Date());
		
		grid.on("rowclick", function (e) {
              //alert(e.record.mid);//弹个ID出来就好了	
			  
					showWindow();
         });
		
        var db = new mini.DataBinding();
        db.bindForm("editForm1", grid);
		
		function showWindow() {
			var win = mini.get("win1");
			win.show();
		}
		
        //对"createtime"字段，进行降级排序
        grid.sortBy("fid", "desc");
      /////////////////////////////////
		function onActionRenderer(e) {
             var grid = e.sender;
            var record = e.record;
            var uid = record._uid;
            var rowIndex = e.rowIndex;

            var s = ' <a class="Edit_Button" href="javascript:download(\'' + uid + '\')">下载</a>'
                    + ' <a class="Delete_Button" href="javascript:deletefile(\'' + uid + '\')">删除</a>';         
            return s;
        }
        function download(row_uid){
			var row = grid.getRowByUID(row_uid);
			//alert(row.orginalname);
			window.location.href="__APP__/File/down?name="+row.orginalname+"&level="+row.level;
			//alert("__APP__/File/down?name="+row.orginalname+"&level="+row.level);
		
		}
		function batchdown(){
		
		if(grid.getData()=="")
		{	mini.alert("无文件!");
			return;
        }	
        	window.location.href="__APP__/File/downall/project/{$_SESSION['pname']}";
        }
		 function deletefile(row_uid){
			var row = grid.getRowByUID(row_uid);
			//alert(row.orginalname);
			window.location.href="__PUBLIC__/php/delete.php?name="+row.orginalname;
			//alert("__APP__/File/down?name="+row.orginalname+"&level="+row.level);
		
		}
		
        function search() {
            var key=document.getElementById("key").value;
			
            grid.load({ key: key});
        }
		
       

        ///////////////////////////////////////////////////////
		 function add() {

            var win = mini.get("win2");
			win.show();
        }
		

		
		function ExportExcel() {
           var pid="{$_SESSION['pid']}";
			var tablename="company_finance";
           	var filename="项目公司财务数据摘要";
			window.location.href="__APP__/File/exportexcel?tablename="+tablename+"&filename="+filename+"&pid="+pid;
       

        }
        
		 function addForm() {
			//提交表单数据
            var form = new mini.Form("#addForm1");            
            var data = form.getData(true);      //获取表单多个控件的数据
            
            $.ajax({
                url: "__APP__/Post/post_4_add",
                type: "post",
                data: { Data: data },
                success: function (text) {
                    alert("提交成功");
                    grid.reload();
                    var win = mini.get("win2");
					win.hide();
                }
            });

        }
		
		  function resetForm() {
            var form = new mini.Form("#addForm1");
            form.reset();
        }
		function CloseWindow(action) {

        if (window.CloseOwnerWindow) window.CloseOwnerWindow(action);

        else window.close();

    	} 
    </script>

    


  

</body>
</html>